package com.cruel_wandering.wifi_geo_predictor.wifi_simulation;

import java.util.LinkedList;
import java.util.List;

import android.content.Context;
import android.net.DhcpInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;

/**
 * This class was created to provide us the ability to simulate wifi manager.
 * For now, there is no possibility to simulate Wifi on android emulator.
 * The given class is a workaround for the problem.
 * @author wmii
 *
 */
public class WifiManagerWrapper extends MyWifiManager
{
	private WifiManager manager = null;

	public WifiManagerWrapper(Context ctx)
  {
		super();
		manager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
  }

	@Override
  public int addNetwork(WifiConfiguration config)
  {
		return manager.addNetwork(config);
  }

	@Override
  public WifiLock createWifiLock(int lockType, String tag)
  {
		return manager.createWifiLock(lockType, tag);
  }

	@Override
  public WifiLock createWifiLock(String tag)
  {
		return manager.createWifiLock(tag);
  }

	@Override
  public boolean disableNetwork(int netId)
  {
		return manager.disableNetwork(netId);
  }

	@Override
  public boolean disconnect()
  {
		return manager.disconnect();
  }

	@Override
  public boolean enableNetwork(int netId, boolean disableOthers)
  {
		return manager.enableNetwork(netId, disableOthers);
  }

	@Override
  public List<WifiConfiguration> getConfiguredNetworks()
  {
		return manager.getConfiguredNetworks();
  }

	@Override
  public MyWifiInfo getConnectionInfo()
  {
		return new MyWifiInfo(manager.getConnectionInfo());
  }

	@Override
  public DhcpInfo getDhcpInfo()
  {
		return manager.getDhcpInfo();
  }

	@Override
  public List<MyScanResult> getScanResults()
  {
	List<MyScanResult> res = new LinkedList<MyScanResult>();

	for (ScanResult sr : manager.getScanResults())
		res.add(new MyScanResult(sr));
	return res;
  }

	@Override
  public int getWifiState()
  {
		return manager.getWifiState();
  }

	@Override
  public boolean isWifiEnabled()
  {
		return manager.isWifiEnabled();
  }

	@Override
  public boolean pingSupplicant()
  {
		return manager.pingSupplicant();
  }

	@Override
  public boolean reassociate()
  {
		return manager.reassociate();
  }

	@Override
  public boolean reconnect()
  {
		return manager.reconnect();
  }

	@Override
  public boolean removeNetwork(int netId)
  {
		return manager.removeNetwork(netId);
  }

	@Override
  public boolean saveConfiguration()
  {
		return manager.saveConfiguration();
  }

	@Override
  public boolean setWifiEnabled(boolean enabled)
  {
		return manager.setWifiEnabled(enabled);
  }

	@Override
  public boolean startScan()
  {
		return manager.startScan();
  }

	@Override
  public int updateNetwork(WifiConfiguration config)
  {
		return manager.updateNetwork(config);
  }
}
